const result = require("./hand")

const abnormal = async(ctx,next)=>{
    try {
        await next()
    } catch (error) {
        const isresult = error instanceof result
        if(isresult){
            ctx.body = {
                msg:error.msg
            }
            ctx.status = error.code
        } else{
            ctx.body = {
                msg:"服务器出现未知错误"
            }
            ctx.status = error.code
        }
    }
}
module.exports = abnormal